package com.example.slack;

import static com.slack.api.model.block.Blocks.*;
import static com.slack.api.model.block.composition.BlockCompositions.*;
import static com.slack.api.model.block.element.BlockElements.*;

import com.example.slack.config.ModelConfiguratorConcrete;
import com.slack.api.Slack;
import com.slack.api.methods.response.chat.ChatPostMessageResponse;
import com.slack.api.model.block.Blocks;
import com.slack.api.model.block.ImageBlock;
import com.slack.api.model.block.LayoutBlock;
import com.slack.api.model.block.composition.TextObject;

import java.util.List;

public class ChatPostMessage2 {
    public static void main(String[] args) throws Exception {
        String channelId = "D07JVNVJWVC";
        String text = "哈哈哈";

        Slack slack = Slack.getInstance();
        String token = "xoxb-5118834517970-7648408831154-7qofPkl0P2pxKziEw7QZMi50";

//        ChatPostMessageResponse response = slack.methods(token).chatPostMessage(req -> req
//                .channel(channelId)
//                .text(text)
//        );
        List<LayoutBlock> layoutBlocks = Blocks.asBlocks(Blocks.section(section -> section.text(plainText("你好啊"))));
        List<LayoutBlock> imgBlocks = Blocks.asBlocks(
                Blocks.image(v -> v.imageUrl("https://assets3.thrillist.com/v1/image/1682388/size/tl-horizontal_main.jpg").altText("美食")));
        ChatPostMessageResponse response = slack.methods(token).chatPostMessage(req -> req
                .channel(channelId)
                .blocks(imgBlocks));
        slack.close();
    }
}
